home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / mordor_2.000 / mordor_2 / src / command5.c < prev    next >
C/C++ Source or Header  |  1995-06-28  |  28KB  |  912 lines

  1. /*
  2.  * COMMAND5.C:
  3.  *
  4.  *  Additional user routines.
  5.  *
  6.  *  Copyright (C) 1991, 1992, 1993 Brett J. Vickers
  7.  *
  8.  */
  9.  
  10. #include "mstruct.h"
  11. #include "mextern.h"
  12. #include <ctype.h>
  13.  
  14. /**********************************************************************/
  15. /*              attack                    */
  16. /**********************************************************************/
  17.  
  18. /* This function allows the player pointed to by the first parameter */
  19. /* to attack a monster.                          */
  20.  
  21. int attack(ply_ptr, cmnd)
  22. creature    *ply_ptr;
  23. cmd     *cmnd;
  24. {
  25.     creature    *crt_ptr;
  26.     room        *rom_ptr;
  27.     long        i, t;
  28.     int     fd;
  29.  
  30.  
  31.     fd = ply_ptr->fd;
  32.  
  33.     t = time(0);
  34.     i = LT(ply_ptr, LT_ATTCK);
  35.  
  36.     if(t < i) {
  37.         please_wait(fd, i-t);
  38.         return(0);
  39.     }
  40.  
  41.     if(cmnd->num < 2) {
  42.         print(fd, "Attack what?\n");
  43.         return(0);
  44.     }
  45.  
  46.     rom_ptr = ply_ptr->parent_rom;
  47.  
  48.     crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon,
  49.                cmnd->str[1], cmnd->val[1]);
  50.  
  51.     if(!crt_ptr) {
  52.         cmnd->str[1][0] = up(cmnd->str[1][0]);
  53.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  54.                    cmnd->str[1], cmnd->val[1]);
  55.  
  56.         if(!crt_ptr || crt_ptr == ply_ptr || strlen(cmnd->str[1]) < 3) {
  57.             print(fd, "You don't see that here.\n");
  58.             return(0);
  59.         }
  60.  
  61.     }
  62.  
  63.     attack_crt(ply_ptr, crt_ptr);
  64.  
  65.     return(0);
  66.  
  67. }
  68.  
  69. /**********************************************************************/
  70. /*              attack_crt                */
  71. /**********************************************************************/
  72.  
  73. /* This function does the actual attacking.  The first parameter contains */
  74. /* a pointer to the attacker and the second contains a pointer to the     */
  75. /* victim.  A 1 is returned if the attack restults in death.          */
  76.  
  77. int attack_crt(ply_ptr, crt_ptr)
  78. creature    *ply_ptr;
  79. creature    *crt_ptr;
  80. {
  81.     long    i, t;
  82.     int fd, m, n, p, lev, addprof;
  83.  
  84.     fd = ply_ptr->fd;
  85.  
  86.     t = time(0);
  87.     i = LT(ply_ptr, LT_ATTCK);
  88.  
  89.     if(t < i)
  90.         return(0);
  91.     if (crt_ptr->type != MONSTER) {
  92.          if(is_charm_crt(ply_ptr->name, crt_ptr) && F_ISSET(ply_ptr, PCHARM)) {
  93.                 print(fd, "You like %s too much to do that.\n", crt_ptr->name);
  94.                 return(0);
  95.          }
  96.     else
  97.         del_charm_crt(ply_ptr->name, crt_ptr);
  98.  
  99.     }
  100.     F_CLR(ply_ptr, PHIDDN);
  101.     if(F_ISSET(ply_ptr, PINVIS)) {
  102.         F_CLR(ply_ptr, PINVIS);
  103.         print(fd, "Your invisibility fades.\n");
  104.         broadcast_rom(fd, ply_ptr->rom_num, "%M fades into view.",
  105.                   ply_ptr);
  106.     }
  107.  
  108.     ply_ptr->lasttime[LT_ATTCK].ltime = t;
  109.     if(F_ISSET(ply_ptr, PHASTE))
  110.         ply_ptr->lasttime[LT_ATTCK].interval = 2;
  111.     else
  112.         ply_ptr->lasttime[LT_ATTCK].interval = 3;
  113.     if(F_ISSET(ply_ptr, PBLIND)){
  114.         ply_ptr->lasttime[LT_ATTCK].interval = 7;
  115.         }
  116.     if(crt_ptr->type == MONSTER) {
  117.         if(F_ISSET(crt_ptr, MUNKIL)) {
  118.             print(fd, "You cannot harm %s.\n",
  119.                 F_ISSET(crt_ptr, MMALES) ? "him":"her");
  120.             return(0);
  121.         }
  122.  
  123.         if(add_enm_crt(ply_ptr->name, crt_ptr) < 0) {
  124.             print(fd, "You attack %m.\n", crt_ptr);
  125.             broadcast_rom(fd, ply_ptr->rom_num, "%M attacks %m.",
  126.                       ply_ptr, crt_ptr);
  127.         }
  128.  
  129.  
  130.         if(F_ISSET(crt_ptr, MMGONL)) {
  131.             print(fd, "Your weapon has no effect on %m.\n",
  132.                 crt_ptr);
  133.             return(0);
  134.         }
  135.         if(F_ISSET(crt_ptr, MENONL)) {
  136.             if(!ply_ptr->ready[WIELD-1] || 
  137.                 ply_ptr->ready[WIELD-1]->adjustment < 1) {
  138.                 print(fd, "Your weapon has no effect on %m.\n",
  139.                     crt_ptr);
  140.                 return(0);
  141.             }
  142.         }
  143.     }
  144.     else {
  145.         if(F_ISSET(ply_ptr->parent_rom, RNOKIL)) {
  146.             print(fd, "No killing allowed in this room.\n");
  147.             return(0);
  148.         }
  149.  
  150.             if((!F_ISSET(ply_ptr,PPLDGK) || !F_ISSET(crt_ptr,PPLDGK)) ||
  151.                 (BOOL(F_ISSET(ply_ptr,PKNGDM)) == BOOL(F_ISSET(crt_ptr,PKNGDM))) ||
  152.                 (! AT_WAR)) {
  153.                 if(!F_ISSET(ply_ptr, PCHAOS)) {
  154.                     print(fd, "Sorry, you're lawful.\n");
  155.                     return (0);
  156.                 }
  157.                 if(!F_ISSET(crt_ptr, PCHAOS)) {
  158.                     print(fd, "Sorry, that player is lawful.\n");
  159.                     return (0);
  160.                 }     
  161.         }
  162.         ply_ptr->lasttime[LT_ATTCK].interval += 5;
  163.         print(crt_ptr->fd, "%M attacked you!\n", ply_ptr);
  164.         broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num, 
  165.                    "%M attacked %m!", ply_ptr, crt_ptr);
  166.     }
  167.  
  168.     if(ply_ptr->ready[WIELD-1]) {
  169.         if(ply_ptr->ready[WIELD-1]->shotscur < 1) {
  170.             print(fd, "Your %s is broken.\n", 
  171.                   ply_ptr->ready[WIELD-1]->name);
  172.             broadcast_rom(fd, ply_ptr->rom_num, "%M broke %s %s.",
  173.                 ply_ptr,
  174.                 F_ISSET(ply_ptr, PMALES) ? "his":"her",
  175.                 ply_ptr->ready[WIELD-1]->name);
  176.             add_obj_crt(ply_ptr->ready[WIELD-1], ply_ptr);
  177.             ply_ptr->ready[WIELD-1] = 0;
  178.             return(0);
  179.         }
  180.     }
  181.  
  182.     n = ply_ptr->thaco - crt_ptr->armor/10;
  183.     
  184.     if (F_ISSET(ply_ptr, PFEARS))
  185.         n += 2;
  186.  
  187.     if (F_ISSET(ply_ptr, PBLIND))
  188.         n += 5;
  189.  
  190.     if(mrand(1,20) >= n) {
  191.         if(ply_ptr->ready[WIELD-1])
  192.             n = mdice(ply_ptr->ready[WIELD-1]) + 
  193.                 bonus[ply_ptr->strength];
  194.         else
  195.             n = mdice(ply_ptr) + bonus[ply_ptr->strength];
  196.  
  197.         if(crt_ptr->class >= CARETAKER) 
  198.             n = 0;
  199.         n = MAX(1,n);
  200.  
  201.         if(ply_ptr->class == PALADIN) {
  202.             if(ply_ptr->alignment < 0) {
  203.                 n /= 2;
  204.                 print(fd, "Your evilness reduces your damage.\n");
  205.             }
  206.             else if(ply_ptr->alignment > 250) {
  207.                 n += mrand(1,3);
  208.                 print(fd, "Your goodness increases your damage.\n");
  209.             }
  210.         }
  211.  
  212.         p = mod_profic(ply_ptr);
  213.         if(mrand(1,100) <= p || (ply_ptr->ready[WIELD-1] && F_ISSET(ply_ptr->ready[WIELD-1],OALCRT))) {
  214.             ANSI(fd, GREEN);
  215.             print(fd, "CRITICAL HIT!\n");
  216.             ANSI(fd, WHITE);
  217.             broadcast_rom(fd, ply_ptr->rom_num,
  218.                 "%M made a critical hit.", ply_ptr);
  219.             n *= mrand(3,6);
  220.             if(ply_ptr->ready[WIELD-1] && (!F_ISSET(ply_ptr->ready[WIELD-1], ONSHAT)) && ((mrand(1,100) < 3) || (F_ISSET(ply_ptr->ready[WIELD-1],OALCRT)))) {
  221.                 print(fd, "Your %s shatters.\n",
  222.                     ply_ptr->ready[WIELD-1]->name);
  223.                 broadcast_rom(fd, ply_ptr->rom_num,
  224.                     "%s %s shattered.",
  225.                     F_ISSET(ply_ptr, PMALES) ? "His":"Her",
  226.                     ply_ptr->ready[WIELD-1]->name);
  227.                 free_obj(ply_ptr->ready[WIELD-1]);
  228.                 ply_ptr->ready[WIELD-1] = 0;
  229.             }
  230.         }
  231.         else if(mrand(1,100) <= (5-p) && ply_ptr->ready[WIELD-1] &&
  232.             !F_ISSET(ply_ptr->ready[WIELD-1], OCURSE)) {
  233.             ANSI(fd, GREEN);
  234.             print(fd, "You FUMBLED your weapon.\n");
  235.             ANSI(fd, WHITE);
  236.             broadcast_rom(fd, ply_ptr->rom_num, 
  237.                 "%M fumbled %s weapon.", ply_ptr,
  238.                 F_ISSET(ply_ptr, PMALES) ? "his":"her");
  239.             n = 0;
  240.             add_obj_crt(ply_ptr->ready[WIELD-1], ply_ptr);
  241.             ply_ptr->ready[WIELD-1] = 0;
  242.             compute_thaco(ply_ptr);
  243.         }
  244.  
  245.         print(fd, "You hit for %d damage.\n", n);
  246.         print(crt_ptr->fd, "%M hit you for %d damage.\n",
  247.               ply_ptr, n);
  248.  
  249.         if(ply_ptr->ready[WIELD-1] && !mrand(0,3))
  250.             ply_ptr->ready[WIELD-1]->shotscur--;
  251.  
  252.         m = MIN(crt_ptr->hpcur, n);
  253.         crt_ptr->hpcur -= n;
  254.         if(crt_ptr->type != PLAYER) {
  255.             add_enm_dmg(ply_ptr->name, crt_ptr, m);
  256.             if(ply_ptr->ready[WIELD-1]) {
  257.                 p = MIN(ply_ptr->ready[WIELD-1]->type, 4);
  258.                 addprof = (m * crt_ptr->experience) /
  259.                     MAX(crt_ptr->hpmax, 1);
  260.                 addprof = MIN(addprof, crt_ptr->experience);
  261.                 ply_ptr->proficiency[p] += addprof;
  262.             }
  263.         }
  264.  
  265.         if(crt_ptr->hpcur < 1) {
  266.             print(fd, "You killed %m.\n", crt_ptr);
  267.             broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num,
  268.                       "%M killed %m.", ply_ptr, crt_ptr);
  269.             die(crt_ptr, ply_ptr);
  270.             return(1);
  271.         }
  272.         else
  273.             check_for_flee(crt_ptr);
  274.     }
  275.     else {
  276.         print(fd, "You missed.\n");
  277.         print(crt_ptr->fd, "%M missed.\n", ply_ptr);
  278.     }
  279.  
  280.     return(0);
  281. }
  282.  
  283. /**********************************************************************/
  284. /*              who                   */
  285. /**********************************************************************/
  286.  
  287. /* This function outputs a list of all the players who are currently */
  288. /* logged into the game.  It includes their titles and the last      */
  289. /* command they typed.                           */
  290.  
  291. int who(ply_ptr, cmnd)
  292. creature    *ply_ptr;
  293. cmd     *cmnd;
  294. {
  295.     char    str[15];
  296.     int fd, i, j;
  297.  
  298.     fd = ply_ptr->fd;
  299.  
  300.      if(F_ISSET(ply_ptr, PBLIND)){
  301.                 ANSI(fd, RED);
  302.                 print(fd, "You're blind!\n");
  303.                 ANSI(fd, WHITE);
  304.                 return(0);
  305.         }
  306.  
  307. #ifdef LASTCOMMAND
  308.     print(fd, "%-23s  %-20s     %-20s\n", "Player", "Title", "Last command");
  309. #else
  310.     ANSI (fd, BOLD);
  311.     ANSI (fd, BLUE);
  312.     print(fd, "%-23s  %-20s     %-20s\n", "Player", "Title", "Race");
  313. #endif
  314.     print(fd, "-----------------------------------------------------------------\n");
  315.     ANSI(fd, NORMAL);
  316.     ANSI(fd, WHITE);
  317.     for(i=0; i<Tablesize; i++) {
  318.         if(!Ply[i].ply) continue;
  319.         if(Ply[i].ply->fd == -1) continue;
  320.         if(F_ISSET(Ply[i].ply, PDMINV) && Ply[i].ply->class == DM &&
  321.            ply_ptr->class < CARETAKER)
  322.             continue;
  323.         if(F_ISSET(Ply[i].ply, PDMINV) && ply_ptr->class < DM)
  324.             continue;
  325.         if(F_ISSET(Ply[i].ply, PINVIS) && !F_ISSET(ply_ptr, PDINVI) &&
  326.            ply_ptr->class < CARETAKER)
  327.             continue;
  328.     ANSI(fd, WHITE);
  329.         print(fd, "%-20s%s  ", Ply[i].ply->name, 
  330.               (F_ISSET(Ply[i].ply, PDMINV) ||
  331.               F_ISSET(Ply[i].ply, PINVIS)) ? "(*)":"   ");
  332.             ANSI(fd, GREEN);
  333.      print(fd, "%-20s     ", title_ply(Ply[i].ply));
  334.      ANSI(fd, WHITE);
  335. #ifdef LASTCOMMAND
  336.         strncpy(str, Ply[i].extr->lastcommand, 14);
  337.         for(j=0; j<15; j++)
  338.             if(str[j] == ' ') {
  339.                 str[j] = 0;
  340.                 break;
  341.             }
  342.         if(!str[0])
  343.             print(fd, "Logged in\n");
  344.         else
  345.             print(fd, "%s\n", str);
  346. #else
  347.     ANSI(fd, CYAN);
  348.         print(fd, "%-14s\n", race_str[Ply[i].ply->race]);
  349.     ANSI(fd, WHITE);
  350. #endif
  351.     }
  352.     print(fd, "\n");
  353.  
  354.     return(0);
  355.  
  356. }
  357.  
  358. /**********************************************************************/
  359. /*                              whois                                 */
  360. /**********************************************************************/
  361. /* The whois function displays a selected player's name, class, level *
  362.  * title, age and gender */
  363.       
  364. int whois(ply_ptr, cmnd)
  365. creature    *ply_ptr;
  366. cmd     *cmnd;
  367. {
  368.     creature    *crt_ptr;
  369.     int     fd;
  370.  
  371.     fd = ply_ptr->fd;
  372.  
  373.     if(cmnd->num < 2) {
  374.         print(fd, "Whois who?\n");
  375.         return(0);
  376.     }
  377.  
  378.     lowercize(cmnd->str[1], 1);
  379.     crt_ptr = find_who(cmnd->str[1]);
  380.  
  381.     if(!crt_ptr || F_ISSET(crt_ptr, PDMINV) || F_ISSET(ply_ptr, PBLIND) ||
  382.        (F_ISSET(crt_ptr, PINVIS) && !F_ISSET(ply_ptr, PDINVI))) {
  383.         print(fd, "That player is not logged on.\n");
  384.         return(0);
  385.     }
  386.  
  387.     ANSI(fd, YELLOW); 
  388.        print(fd, "%-20s  %-3s %-3s [Lv]%-20s  %-3s  %-10s\n", "Player", "Cls", "Gen", "Title", "Age", "Race");
  389.         print(fd, "------------------------------------------------------------------------\n");
  390.         print(fd, "%-20s  %-3.3s %-3s [%02d]%-20s  %-3d  ",
  391.                 crt_ptr->name,
  392.                 class_str[crt_ptr->class],
  393.                 F_ISSET(crt_ptr, PMALES) ? " M":" F",  
  394.                 crt_ptr->level,
  395.                 title_ply(crt_ptr), 
  396.                 18 + crt_ptr->lasttime[LT_HOURS].interval/86400L);
  397. print(fd, "%-10s\n", race_str[crt_ptr->race]);
  398.      ANSI(fd, NORMAL);
  399.      ANSI(fd, WHITE);
  400.     return(0);
  401. }
  402.  
  403. /**********************************************************************/
  404. /*              search                    */
  405. /**********************************************************************/
  406.  
  407. /* This function allows a player to search a room for hidden objects,  */
  408. /* exits, monsters and players.                        */
  409.  
  410. int search(ply_ptr, cmnd)
  411. creature    *ply_ptr;
  412. cmd     *cmnd;
  413. {
  414.     room    *rom_ptr;
  415.     xtag    *xp;
  416.     otag    *op;
  417.     ctag    *cp;
  418.     long    i, t;
  419.     int fd, chance, found = 0;
  420.  
  421.     fd = ply_ptr->fd;
  422.     rom_ptr = ply_ptr->parent_rom;
  423.  
  424.     chance = 15 + 5*bonus[ply_ptr->piety] + ply_ptr->level*2;
  425.     chance = MIN(chance, 90);
  426.     if(ply_ptr->class == RANGER)
  427.         chance += ply_ptr->level*8;
  428.     if(F_ISSET(ply_ptr, PBLIND))
  429.     chance = MIN(chance, 20);
  430.     if(ply_ptr->class >= CARETAKER)
  431.         chance = 100;
  432.  
  433.     t = time(0);
  434.     i = LT(ply_ptr, LT_SERCH);
  435.  
  436.     if(t < i) {
  437.         please_wait(fd, i-t);
  438.         return(0);
  439.     }
  440.  
  441.     F_CLR(ply_ptr, PHIDDN);
  442.  
  443.     ply_ptr->lasttime[LT_SERCH].ltime = t;
  444.     if(ply_ptr->class == RANGER)
  445.         ply_ptr->lasttime[LT_SERCH].interval = 3;
  446.     else
  447.         ply_ptr->lasttime[LT_SERCH].interval = 7;
  448.  
  449.     xp = rom_ptr->first_ext;
  450.     while(xp) {
  451.         if(F_ISSET(xp->ext, XSECRT) && mrand(1,100) <= chance) 
  452.            if((F_ISSET(xp->ext, XINVIS) && F_ISSET(ply_ptr,PDINVI) ||
  453.             !F_ISSET(xp->ext, XINVIS)) && !F_ISSET(xp->ext, XNOSEE)){
  454.             found++;
  455.             print(fd, "You found an exit: %s.\n", xp->ext->name);
  456.         }
  457.         xp = xp->next_tag;
  458.     }
  459.  
  460.     op = rom_ptr->first_obj;
  461.     while(op) {
  462.         if(F_ISSET(op->obj, OHIDDN) && mrand(1,100) <= chance) 
  463.         if(F_ISSET(op->obj, OINVIS) && F_ISSET(ply_ptr,PDINVI) ||
  464.             !F_ISSET(op->obj, OINVIS)){
  465.             found++;
  466.             print(fd, "You found %1i.\n", op->obj);
  467.         }
  468.         op = op->next_tag;
  469.     }
  470.  
  471.     cp = rom_ptr->first_ply;
  472.     while(cp) {
  473.         if(F_ISSET(cp->crt, PHIDDN) && !F_ISSET(cp->crt, PDMINV) &&
  474.            mrand(1,100) <= chance) 
  475.         if(F_ISSET(cp->crt, PINVIS) && F_ISSET(ply_ptr,PDINVI) ||
  476.             !F_ISSET(cp->crt, PINVIS)){
  477.             found++;
  478.             print(fd, "You found %s hiding.\n", cp->crt->name);
  479.         }
  480.         cp = cp->next_tag;
  481.     }
  482.  
  483.     cp = rom_ptr->first_mon;
  484.     while(cp) {
  485.         if(F_ISSET(cp->crt, MHIDDN) && mrand(1,100) <= chance) 
  486.         if(F_ISSET(cp->crt, MINVIS) && F_ISSET(ply_ptr,PDINVI) ||
  487.             !F_ISSET(cp->crt, MINVIS)){
  488.             found++;
  489.             print(fd, "You found %1m hiding.\n", cp->crt);
  490.         }
  491.         cp = cp->next_tag;
  492.     }
  493.  
  494.     broadcast_rom(fd, ply_ptr->rom_num, "%M searches the room.", ply_ptr);
  495.  
  496.     if(found)
  497.         broadcast_rom(fd, ply_ptr->rom_num, "%s found something!", 
  498.                   F_ISSET(ply_ptr, MMALES) ? "He":"She");
  499.     else
  500.         print(fd, "You didn't find anything.\n");
  501.  
  502.     return(0);
  503.  
  504. }
  505.  
  506. /**********************************************************************/
  507. /*              ply_suicide               */
  508. /**********************************************************************/
  509.  
  510. /* This function is called whenever the player explicitly asks to     */
  511. /* commit suicide.  It then calls the suicide() function which takes  */
  512. /* over that player's input.                          */
  513.  
  514. int ply_suicide(ply_ptr, cmnd)
  515. creature    *ply_ptr;
  516. cmd     *cmnd;
  517. {
  518.     suicide(ply_ptr->fd, 1, "");
  519.     return(DOPROMPT);
  520. }
  521.  
  522. /**********************************************************************/
  523. /*              suicide                   */
  524. /**********************************************************************/
  525.  
  526. /* This function allows a player to kill himself, thus erasing his entire */
  527. /* player file.                               */
  528.  
  529. void suicide(fd, param, str)
  530. int fd;
  531. int param;
  532. char    *str;
  533. {
  534.     char    file[80];
  535.  
  536.     switch(param) {
  537.         case 1:
  538.         ANSI(fd, BOLD);
  539.         ANSI(fd, RED);
  540.             print(fd, "This will completely erase your player.\n");
  541.             print(fd, "Are you sure (Y/N)");
  542.         ANSI(fd, NORMAL);
  543.         ANSI(fd, WHITE);
  544.             RETURN(fd, suicide, 2);
  545.         case 2:
  546.             if(low(str[0]) == 'y') {
  547.                 broadcast("### %s committed suicide! We'll miss %s dearly.", Ply[fd].ply->name, F_ISSET(Ply[fd].ply, PMALES) ? "him":"her");
  548.                 sprintf(file, "%s/%s", PLAYERPATH, 
  549.                     Ply[fd].ply->name);
  550. #ifdef SUICIDE
  551.         logn("SUICIDE","%s (%s) suicided.\n", Ply[fd].ply->name, Ply[fd].io->address);
  552. #endif
  553.         disconnect(fd);
  554.                 unlink(file);
  555.                 return;
  556.             }
  557.             else {
  558.                 print(fd, "Aborted.\n");
  559.                 RETURN(fd, command, 1);
  560.             }
  561.     }
  562. }
  563.  
  564. /**********************************************************************/
  565. /*              hide                      */
  566. /**********************************************************************/
  567.  
  568. /* This command allows a player to try and hide himself in the shadows */
  569. /* or it can be used to hide an object in a room.              */
  570.  
  571. int hide(ply_ptr, cmnd)
  572. creature    *ply_ptr;
  573. cmd     *cmnd;
  574. {
  575.     room    *rom_ptr;
  576.     object  *obj_ptr;
  577.     long    i, t;
  578.     int fd, chance;
  579.  
  580.     fd = ply_ptr->fd;
  581.     rom_ptr = ply_ptr->parent_rom;
  582.  
  583.     i = LT(ply_ptr, LT_HIDES);
  584.     t = time(0);
  585.  
  586.     if(i > t) {
  587.         please_wait(fd, i-t);
  588.         return(0);
  589.     }
  590.  
  591.     ply_ptr->lasttime[LT_HIDES].ltime = t;
  592.     ply_ptr->lasttime[LT_HIDES].interval = (ply_ptr->class == THIEF ||
  593.         ply_ptr->class == ASSASSIN || ply_ptr->class == RANGER) ? 5:15;
  594.  
  595.     if(cmnd->num == 1) {
  596.  
  597.         if(ply_ptr->class == THIEF || ply_ptr->class == ASSASSIN)
  598.             chance = MIN(90, 5 + 6*ply_ptr->level + 
  599.                 3*bonus[ply_ptr->dexterity]);
  600.         else if(ply_ptr->class == RANGER)
  601.             chance = 5 + 10*ply_ptr->level +
  602.                 3*bonus[ply_ptr->dexterity];
  603.         else
  604.             chance = MIN(90, 5 + 2*ply_ptr->level +
  605.                 3*bonus[ply_ptr->dexterity]);
  606.  
  607.         print(fd, "You attempt to hide in the shadows.\n");
  608.  
  609.     if(F_ISSET(ply_ptr, PBLIND))
  610.         chance = MIN(chance, 20);
  611.  
  612.         if(mrand(1,100) <= chance)
  613.             F_SET(ply_ptr, PHIDDN);
  614.         else {
  615.             F_CLR(ply_ptr, PHIDDN);
  616.             broadcast_rom(fd, ply_ptr->rom_num,
  617.                   "%M tries to hide in the shadows.", ply_ptr);
  618.         }
  619.  
  620.  
  621.         return(0);
  622.  
  623.     }
  624.  
  625.     obj_ptr = find_obj(ply_ptr, rom_ptr->first_obj,
  626.                cmnd->str[1], cmnd->val[1]);
  627.  
  628.     if(!obj_ptr) {
  629.         print(fd, "I don't see that here.\n");
  630.         return(0);
  631.     }
  632.  
  633.     if(F_ISSET(obj_ptr,ONOTAK)){
  634.     print(fd,"You can not hide that.\n");
  635.     return (0);
  636.    }
  637.     if(ply_ptr->class == THIEF || ply_ptr->class == ASSASSIN)
  638.         chance = MIN(90, 10 + 5*ply_ptr->level + 
  639.             5*bonus[ply_ptr->dexterity]);
  640.     else if(ply_ptr->class == RANGER)
  641.         chance = 5 + 9*ply_ptr->level +
  642.             3*bonus[ply_ptr->dexterity];
  643.     else
  644.         chance = MIN(90, 5 + 3*ply_ptr->level + 
  645.             3*bonus[ply_ptr->dexterity]);
  646.  
  647.     print(fd, "You attempt to hide it.\n");
  648.     broadcast_rom(fd, ply_ptr->rom_num, "%M attempts to hide %1i.", 
  649.               ply_ptr, obj_ptr);
  650.  
  651.     if(mrand(1,100) <= chance)
  652.         F_SET(obj_ptr, OHIDDN);
  653.     else
  654.         F_CLR(obj_ptr, OHIDDN);
  655.  
  656.     return(0);
  657.  
  658. }
  659.  
  660. /************************************************************************/
  661. /************************************************************************/
  662.  
  663. /*  Display information on creature given to player given.        */
  664.  
  665. int flag_list(ply_ptr, cmnd)
  666. creature    *ply_ptr;
  667. cmd            *cmnd;
  668. {
  669.     char        str[1024], temp[20];
  670.     int        i, fd;
  671.  
  672.     str[0] = 0;
  673.     temp[0] = 0;
  674.  
  675.     fd = ply_ptr->fd;
  676.  
  677.         print(fd,"Flags currently set:\n");
  678.         if(F_ISSET(ply_ptr, PNOBRD)) strcat(str, "NoBroad\n");
  679.         if(F_ISSET(ply_ptr, PNOLDS)) strcat(str, "No Long Room Description\n");
  680.         if(F_ISSET(ply_ptr, PNOSDS)) strcat(str, "No Short Room Description\n");
  681.         if(F_ISSET(ply_ptr, PNORNM)) strcat(str, "NoName\n");
  682.         if(F_ISSET(ply_ptr, PNOEXT)) strcat(str, "NoExits\n");
  683.         if(F_ISSET(ply_ptr, PLECHO)) strcat(str, "Communications echo\n");
  684.         if(F_ISSET(ply_ptr, PNOCMP)) strcat(str, "Noncompact\n");
  685.         if(F_ISSET(ply_ptr, PWIMPY)) {
  686.             sprintf(temp, "Wimpy%d\n", ply_ptr->WIMPYVALUE);
  687.             strcat(str, temp);
  688.         }
  689.         if(F_ISSET(ply_ptr, PPROMP)) strcat(str, "Prompt\n");
  690.         if(F_ISSET(ply_ptr, PANSIC)) strcat(str, "Ansi output mode\n");
  691.         if(F_ISSET(ply_ptr, PIGNOR)) strcat(str, "Ignore all sends\n");
  692.         if(F_ISSET(ply_ptr, PNOSUM)) strcat(str, "Nosummon\n");
  693.         if(F_ISSET(ply_ptr, PNOAAT)) strcat(str, "No Auto Attack\n"); 
  694.         if(F_ISSET(ply_ptr, PHASTE)) strcat(str, "Haste\n");
  695.         if(F_ISSET(ply_ptr, PPRAYD)) strcat(str, "Pray\n");
  696.         if(F_ISSET(ply_ptr, PPLDGK))
  697.             if(F_ISSET(ply_ptr, PKNGDM)) strcat(str, "Organization 1\n");
  698.             else strcat(str, "Organization 0\n");
  699.  
  700.         print(fd,"%s\n",str);
  701.  
  702.         print(fd, "Type help set to see a complete list of flags.\n");
  703.     return(0);
  704. }
  705. /**********************************************************************/
  706. /*              set                   */
  707. /**********************************************************************/
  708.  
  709. /* This function allows a player to set certain one-bit flags.  The flags */
  710. /* are settings for options that include brief and verbose display.  The  */
  711. /* clear function handles the turning off of these flags.         */
  712.  
  713. int set(ply_ptr, cmnd)
  714. creature    *ply_ptr;
  715. cmd     *cmnd;
  716. {
  717.     int fd;
  718.     
  719.     fd = ply_ptr->fd;
  720.  
  721.     if(cmnd->num == 1) {
  722.         flag_list(ply_ptr,cmnd);
  723.         return(0);
  724.     }
  725.  
  726.     if(!strcmp(cmnd->str[1], "nobroad")) {
  727.         F_SET(ply_ptr, PNOBRD);
  728.         print(fd, "Broadcast messages disabled.\n");
  729.     }
  730.     else if(!strcmp(cmnd->str[1], "compact")) {
  731.         F_CLR(ply_ptr, PNOCMP);
  732.         print(fd, "Compact mode enabled.\n");
  733.     }
  734.     else if(!strcmp(cmnd->str[1], "roomname")) {
  735.         F_CLR(ply_ptr, PNORNM);
  736.         print(fd, "Room name output enabled.\n");
  737.     }
  738.     else if(!strcmp(cmnd->str[1], "short")) {
  739.         F_CLR(ply_ptr, PNOSDS);
  740.         print(fd, "Short descriptions enabled.\n");
  741.     }
  742.     else if(!strcmp(cmnd->str[1], "long")) {
  743.         F_CLR(ply_ptr, PNOLDS);
  744.         print(fd, "Long descriptions enabled.\n");
  745.     }
  746.     else if(!strcmp(cmnd->str[1], "hexline")) {
  747.         F_SET(ply_ptr, PHEXLN);
  748.         print(fd, "Hexline enabled.\n");
  749.     }
  750.     else if(!strcmp(cmnd->str[1], "echo")) {
  751.         F_SET(ply_ptr, PLECHO);
  752.         print(fd, "Communications echo enabled.\n");
  753.     }
  754.  
  755.     else if(!strcmp(cmnd->str[1], "wimpy")) {
  756.         F_SET(ply_ptr, PWIMPY);
  757.         print(fd, "Wimpy mode enabled.\n");
  758.         ply_ptr->WIMPYVALUE = cmnd->val[1] == 1L ? 10 : cmnd->val[1];
  759.         ply_ptr->WIMPYVALUE = MAX(ply_ptr->WIMPYVALUE, 2);
  760.         print(fd, "Wimpy value set to (%d).\n", ply_ptr->WIMPYVALUE);
  761.     }
  762.     else if(!strcmp(cmnd->str[1], "eavesdropper")) {
  763.         F_SET(ply_ptr, PEAVES);
  764.         print(fd, "Eavesdropper mode enabled.\n");
  765.     }
  766.     else if(!strcmp(cmnd->str[1], "prompt")) {
  767.         F_SET(ply_ptr, PPROMP);
  768.         print(fd, "Prompt in descriptive format.\n");
  769.     }
  770.     else if(!strcmp(cmnd->str[1], "~robot~")) {
  771.         F_SET(ply_ptr, PROBOT);
  772.         print(fd, "Robot mode on.\n");
  773.     }
  774.     else if(!strcmp(cmnd->str[1], "ansi")) {
  775.         F_SET(ply_ptr, PANSIC);
  776.         print(fd, "Color ANSI mode on.\n");
  777.     }
  778.     else if(!strcmp(cmnd->str[1], "nosummon")) {
  779.         F_SET(ply_ptr, PNOSUM);
  780.         print(fd, "Nosummon flag on.\n");
  781.     }
  782.     else if(!strcmp(cmnd->str[1], "ignore")) {
  783.         F_SET(ply_ptr, PIGNOR);
  784.         print(fd, "Ignore all flag on.\n");
  785.     }
  786.     else if(!strcmp(cmnd->str[1], "noauto")) {
  787.         F_SET(ply_ptr, PNOAAT);
  788.         print(fd, "Auto Attack is turned off.\n");
  789.     }
  790.     else
  791.         print(fd, "Unknown flag.\n");
  792.  
  793.     return(0);
  794.  
  795. }
  796.  
  797. /**********************************************************************/
  798. /*              clear                     */
  799. /**********************************************************************/
  800.  
  801. /* Like set, this function allows a player to alter the value of a part- */
  802. /* icular player flag.                           */
  803.  
  804. int clear(ply_ptr, cmnd)
  805. creature    *ply_ptr;
  806. cmd     *cmnd;
  807. {
  808.     int fd;
  809.     
  810.     fd = ply_ptr->fd;
  811.  
  812.     if(cmnd->num == 1) {
  813.         print(fd, "Type help clear to see a list of flags.\n");
  814.         return(0);
  815.     }
  816.  
  817.     if(!strcmp(cmnd->str[1], "nobroad")) {
  818.         F_CLR(ply_ptr, PNOBRD);
  819.         print(fd, "Broadcast messages enabled.\n");
  820.     }
  821.     else if(!strcmp(cmnd->str[1], "compact")) {
  822.         F_SET(ply_ptr, PNOCMP);
  823.         print(fd, "Compact mode disabled.\n");
  824.     }
  825.     else if(!strcmp(cmnd->str[1], "echo")) {
  826.         F_CLR(ply_ptr, PLECHO);
  827.         print(fd, "Communications echo disabled.\n");
  828.     }
  829.     else if(!strcmp(cmnd->str[1], "roomname")) {
  830.         F_SET(ply_ptr, PNORNM);
  831.         print(fd, "Room name output disabled.\n");
  832.     }
  833.     else if(!strcmp(cmnd->str[1], "short")) {
  834.         F_SET(ply_ptr, PNOSDS);
  835.         print(fd, "Short descriptions disabled.\n");
  836.     }
  837.     else if(!strcmp(cmnd->str[1], "long")) {
  838.         F_SET(ply_ptr, PNOLDS);
  839.         print(fd, "Long descriptions disabled.\n");
  840.     }
  841.     else if(!strcmp(cmnd->str[1], "hexline")) {
  842.         F_CLR(ply_ptr, PHEXLN);
  843.         print(fd, "Hex line disabled.\n");
  844.     }
  845.     else if(!strcmp(cmnd->str[1], "wimpy")) {
  846.         F_CLR(ply_ptr, PWIMPY);
  847.         print(fd, "Wimpy mode disabled.\n");
  848.     }
  849.     else if(!strcmp(cmnd->str[1], "eavesdropper")) {
  850.         F_CLR(ply_ptr, PEAVES);
  851.         print(fd, "Eavesdropper mode disabled.\n");
  852.     }
  853.     else if(!strcmp(cmnd->str[1], "prompt")) {
  854.         F_CLR(ply_ptr, PPROMP);
  855.         print(fd, "Prompt in brief mode.\n");
  856.     }
  857.     else if(!strcmp(cmnd->str[1], "~robot~")) {
  858.         F_CLR(ply_ptr, PROBOT);
  859.         print(fd, "Robot mode off.\n");
  860.     }
  861.     else if(!strcmp(cmnd->str[1], "ansi")) {
  862.         F_CLR(ply_ptr, PANSIC);
  863.         print(fd, "Color ANSI off.\n");
  864.     }
  865.     else if(!strcmp(cmnd->str[1], "nosummon")) {
  866.         F_CLR(ply_ptr, PNOSUM);
  867.         print(fd, "Nosummon flag off.\n");
  868.     }
  869.     else if(!strcmp(cmnd->str[1], "ignore")) {
  870.         F_CLR(ply_ptr, PIGNOR);
  871.         print(fd, "Ignore all flag off.\n");
  872.     }
  873.     else if(!strcmp(cmnd->str[1], "noauto")) {
  874.         F_CLR(ply_ptr, PNOAAT);
  875.         print(fd, "Auto attack mode enabled.\n");
  876.     }
  877.     else
  878.         print(fd, "Unknown flag.\n");
  879.  
  880.     return(0);
  881.  
  882. }
  883.  
  884. /**********************************************************************/
  885. /*              quit                      */
  886. /**********************************************************************/
  887.  
  888. /* This function checks to see if a player is allowed to quit yet.  It  */
  889. /* checks to make sure the player isn't in the middle of combat, and if */
  890. /* so, the player is not allowed to quit (and 0 is returned).       */
  891.  
  892. int quit(ply_ptr, cmnd)
  893. creature    *ply_ptr;
  894. cmd     *cmnd;
  895. {
  896.     long    i, t;
  897.     int fd;
  898.  
  899.     fd = ply_ptr->fd;
  900.  
  901.     t = time(0);
  902.     i = LT(ply_ptr, LT_ATTCK) + 20;
  903.  
  904.     if(t < i) {
  905.         please_wait(fd, i-t);
  906.         return(0);
  907.     }
  908.  
  909.     update_ply(ply_ptr);
  910.     return(DISCONNECT);
  911. }
  912.